local jishu = fk.CreateSkill{
  name = "plum__jishu",
}

Fk:loadTranslationTable{
  [jishu.name] = "忌束",
  [":"..jishu.name] = "出牌阶段限一次，你可与一名其他角色交换一张手牌，"
.."若颜色相同，其将体力向你调整1点，否则你将体力向其调整1点。",

  ["#plum__jishu-prompt"] = "忌束：可以与一名其他角色交换一张手牌",
  ["#plum__jishu-exchange"] = "忌束：与 %src 交换一张手牌",
}

local U = require "packages/utility/utility"
local TuntianUtil = require "packages/tuntian_studio/utility"

jishu:addEffect("active", {
  anim_type = "support",
  prompt = "#plum__jishu-prompt",
  card_num = 1,
  target_num = 1,
  can_use = function (self, player)
    return player:usedSkillTimes(jishu.name, Player.HistoryPhase) == 0
  end,
  card_filter = function (self, player, to_select, selected)
    return #selected == 0 and table.contains(player:getCardIds("h"), to_select)
  end,
  target_filter = function (self, player, to_select, selected, selected_cards)
    return #selected == 0 and to_select ~= player
  end,
  on_use = function (self, room, effect)
    local player = effect.from
    local tagret = effect.tos[1]
    local cards = room:askToCards(tagret, {
      min_num = 1,
      max_num = 1,
      skill_name = jishu.name,
      include_equip = false,
      cancelable = false,
      prompt = "#plum__jishu-exchange:"..player.id
    })
    room:swapCards(player, {{player, effect.cards}, {tagret, cards}}, jishu.name)

    if not (player:isAlive() and tagret:isAlive()) then return end
    local getColor = function (id)
      return Fk:getCardById(id).color
    end
    if getColor(cards[1]) == getColor(effect.cards[1]) then
      TuntianUtil.adjustHpTo(tagret, player, 1, jishu.name, player)
    else
      TuntianUtil.adjustHpTo(player, tagret, 1, jishu.name, player)
    end
  end
})

return jishu